CSharpTest.Net
GetEnumerator Method
See Also  Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > BTreeList<T> Class : GetEnumerator Method

Glossary Item Box

Returns an enumerator that iterates through the collection.

Syntax

Visual Basic (Declaration) 
Public Function GetEnumerator() As IEnumerator(Of T)
C# 
public IEnumerator<T> GetEnumerator()

Example

Library/Library.Test/TestBTreeList.cs

C#Copy Code
BTreeList<int> data = new BTreeList<int>(Comparer, GetSample());
BTreeList<int> copy = (BTreeList<int>) ((ICloneable) data).Clone();
using(IEnumerator<int> e1 = data.GetEnumerator())
using(IEnumerator<int> e2 = copy.GetEnumerator())
{
    while(e1.MoveNext() && e2.MoveNext())
    {
        Assert.AreEqual(e1.Current, e2.Current);
    }
    Assert.IsFalse(e1.MoveNext() || e2.MoveNext());
}
VB.NETCopy Code
Dim data As New BTreeList(Of Integer)(Comparer, GetSample())
Dim copy As BTreeList(Of Integer) = DirectCast((DirectCast(data, ICloneable)).Clone(), BTreeList(Of Integer))
Using e1 As IEnumerator(Of Integer) = data.GetEnumerator()
    Using e2 As IEnumerator(Of Integer) = copy.GetEnumerator()
        While e1.MoveNext() AndAlso e2.MoveNext()
            Assert.AreEqual(e1.Current, e2.Current)
        End While
        Assert.IsFalse(e1.MoveNext() OrElse e2.MoveNext())
    End Using
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Generated with Document! X 2011 by Innovasys